﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Domain
{
    /// <summary>
    /// 屠宰信息类
    /// </summary>
    public class SlaughterInfo : AuditableEntity
    {
        private static int _currentIdNumber = 1;

        /// <summary>
        /// 屠宰编号（格式F001，自增）
        /// </summary>
        [Key]
        public string SlaughterId { get; private set; }

        /// <summary>
        /// 关联的生产批次（外键）
        /// </summary>
        public string ProductionBatch { get; set; }

        /// <summary>
        /// 到厂均重（单位：kg，不为空）
        /// </summary>
        public string AverageWeight { get; set; }

        /// <summary>
        /// 到场时间（精确到分钟）
        /// </summary>
        public DateTime ArrivalTime { get; set; }

        /// <summary>
        /// 屠宰时间（精确到分钟）
        /// </summary>
        public DateTime SlaughterTime { get; set; }

        /// <summary>
        /// 屠宰耗时（计算属性，单位：小时）
        /// </summary>
        public double ProcessingHours => (SlaughterTime - ArrivalTime).TotalHours;

        /// <summary>
        /// 构造函数
        /// </summary>
        public SlaughterInfo()
        {
            SlaughterId = $"F{_currentIdNumber.ToString().PadLeft(3, '0')}";
            _currentIdNumber++;
        }
    }
}
